//
//  OrderViewController.m
//  YIChuSeller
//
//  Created by xsj on 2018/11/22.
//  Copyright © 2018年 xiangshengjun. All rights reserved.
//

#import "GXOrderViewController.h"
#import "GXOrderHeaderView.h"
#import "GXTotalOrderController.h"
#import "GXWaitOrderController.h"
#import "GXAcceptOrderController.h"
#import "GXCancelController.h"
@interface GXOrderViewController ()<OrderHeaderViewDelegate>
@property (nonatomic,assign) CGRect publicframe;
@end

@implementation GXOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatUI];
    [self addChildVC];
}
- (void)creatUI{
    UIView * totalView = [[UIView alloc]initWithFrame:CGRectMake(0,0 , kUIScreenWidth , Height_StatusBar+43)];
    totalView.backgroundColor =RGBColor(84, 192, 180);
    [self.view addSubview:totalView];
    GXOrderHeaderView * headerView = [GXOrderHeaderView headView];
    headerView.delegate = self;
    headerView.frame = CGRectMake(0, Height_StatusBar, kUIScreenWidth, 43);
    [totalView addSubview:headerView];
}
-(void)addChildVC{
    GXTotalOrderController * totalVC = [[GXTotalOrderController alloc]init];
    totalVC .view.frame = CGRectMake(0, Height_StatusBar+43, kUIScreenWidth, kUIScreenHeight-Height_TabBar-Height_StatusBar-43);
    _publicframe = totalVC.view.frame;
    [self.view addSubview:totalVC .view];
    [self addChildViewController:totalVC];

    GXWaitOrderController * notOrderVC = [[GXWaitOrderController alloc]init];
    [self addChildViewController:notOrderVC];
    
    GXAcceptOrderController * notArriveVC = [[GXAcceptOrderController alloc]init];
    [self addChildViewController:notArriveVC];
    
    GXCancelController * cancelVC = [[GXCancelController alloc]init];
    [self addChildViewController:cancelVC];
}

#pragma OrderHeaderViewDelegate
- (void)pressButtonChangeViewForTag:(NSInteger)buttonTag
{
    NSInteger index = buttonTag - 101;
    UIViewController * willShowVC = self.childViewControllers[index];
    for (UIViewController * willShow in self.childViewControllers) {
        if (willShowVC == willShow) {
            willShowVC.view.frame = _publicframe;
            [self.view addSubview:willShow.view];
        }else
        {
            [willShow.view removeFromSuperview];
        }
    }
    
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}


@end
